<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 嵌套列表</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <!-- <script src="__PUBLIC__/admin/js/jquery.js"></script> -->

</head>
<style>
    .labels{
        width:50%;
        text-decoration: none;
        box-sizing: border-box;
        margin: 5px 5px;
        padding: 5px 10px;
        border-width: 1px;
        border-style: solid;
        border-color: rgb(231, 234, 236);
        border-radius: 3px;
        background-color: rgb(231, 234, 236);
        cursor:pointer
    }
    .power{
        height:1.5rem;
        width:1.5rem;
        margin: 5px 0;
        vertical-align: middle
    }
    
</style>
<include file="Admin@Index:cache" />
<body class="gray-bg">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <!--<div class="row">-->
            <!--<div class="col-sm-4">-->
                <!--<div id="nestable-menu">-->
                    <!--<button type="button" data-action="expand-all" class="btn btn-white btn-sm">展开所有</button>-->
                    <!--<button type="button" data-action="collapse-all" class="btn btn-white btn-sm">收起所有</button>-->
                <!--</div>-->
            <!--</div>-->
        <!--</div>-->
        <div class="row">
            <div class="col-sm" >
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>权限列表</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="dd" id="nestable">

                            <ol class="dd-list" style="width:50%;left:25%">
                                <!--<div class="" style="width:50%">-->
                                    <!--<input type="" placeholder="请输入职位名称" id="rolename" class="form-control" value="<{$role.rolename}>">-->
                                <!--</div>-->
                                <p></p>
                                <foreach name="list" item="list">
                                    <switch name="list.level">
                                        <case value="1">
                                            <?php echo str_repeat('--',($list['level']-1)*6);?><span style="cursor:pointer" class="glyphicon glyphicon-remove" aria-hidden="true" onclick="del_power('<{$list.id}>')" id="auth<{$list.id}>"></span><label   class="labels" ><{$list.name}></label><a class="btn btn-success" href="javascript:void(0)" onclick="modify_power('<{$list.name}>','<{$list.id}>')">修改</a>
                                        </case>
                                        <case value="2">
                                            <?php echo str_repeat('--',($list['level']-1)*6);?><span style="cursor:pointer" class="glyphicon glyphicon-remove" aria-hidden="true" onclick="del_power('<{$list.id}>')" id="auth<{$list.id}>"></span><label style="width:41%" class="labels" ><{$list.name}></label><a href="javascript:void(0)" class="btn btn-success" onclick="modify_power('<{$list.name}>','<{$list.id}>')">修改</a>
                                        </case>
                                        <case value="3">
                                            <?php echo str_repeat('--',($list['level']-1)*6);?><span style="cursor:pointer" class="glyphicon glyphicon-remove" aria-hidden="true" onclick="del_power('<{$list.id}>')" id="auth<{$list.id}>"></span><label style="width:32%"  class="labels" ><{$list.name}></label><a href="javascript:void(0)" class="btn btn-success" onclick="modify_power('<{$list.name}>','<{$list.id}>')">修改</a>
                                        </case>
                                    </switch>


                              <br>
                                </foreach>
                            </ol>
                            <p></p>
                        </div>


                    </div>
                </div>
            </div>

        </div>
    </div>

    <!-- 全局js -->

    <script src="__PUBLIC__/admin/js/jquery.min.js"></script>
    <script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <script src="__PUBLIC__/admin/js/plugins/layer/layer.min.js"></script>

    <!-- 自定义js -->
    <script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>


    <script type="text/javascript">
        function del_power(id){
            layer.confirm('是否确定删除？',function(){
                $.post('__MODULE__/Power/del_power',{id:id},function(data){
                    if(data.code=='1001'){
                        window.location.reload();
//                        $('#auth'+id).next().remove();
//                        $('#auth'+id).remove();
                    }else{
                        if(data.status=='0'){
                            layer.msg(data.info,{time:2000,icon:5});
                        }else{
                            layer.msg(data.result,{time:2000,icon:5});
                        }
                    }
                });
            });
        }

        function modify_power(name,id){
            html='';
            html+='<div class="modal-body" id="lists" style="height:100%">';
            html+='<form class="form-horizontal">';
            html+='<div class="form-group">';
            html+='<div class="col-sm-12">';
            html+='<input style="height:3rem" type="text" id="name" value="'+name+'" class="form-control">';
            html+='</div>';
            html+='</div>';
            html+='</form>';
            html+='<div class="modal-footer" style="border:0">';
            html+='<a href="javascript:void(0);" onclick="layer.closeAll()" type="button" class="btn btn-default" >关闭</a>';
            html+='<a href="javascript:void(0);" onclick="modify_powers('+id+');" type="button" class="btn btn-primary" >修改</a>';
            html+='</div>';
            html+='</div>';

            layer.open({
                type: 1, //Page层类型
                area: ['300px', '180px'],
                title: '修改名称',
                shade: 0.6, //遮罩透明度
                maxmin: true, //允许全屏最小化
                anim: 1, //0-6的动画形式，-1不开启
                content: html
            });
        }
        function modify_powers(id){
            var name=$('#name').val();
            if(name==''){
                layer.msg('名称不能为空',{time:2000,icon:5});
                return false;
            }
            layer.confirm('是否确定修改？',function(){
                $.post('__MODULE__/Power/modify_power',{name:name,id:id},function(data){
                    if(data.code=='1001'){
                        window.location.reload();
                    }else{
                        if(data.status=='0'){
                            layer.msg(data.info,{time:2000,icon:5});
                        }else{
                            layer.msg(data.result,{time:2000,icon:5});
                        }
                    }
                });
            });
        }
    </script>
    
    
</body>

</html>
